
public class Tools {

	
	
	public static byte[] hexStringToByteArray(String s) {
	    int len = s.length();
	    byte[] data = new byte[len / 2];
	    for (int i = 0; i < len; i += 2) {
	        data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
	                             + Character.digit(s.charAt(i+1), 16));
	    }
	    return data;
	}
	
	public static String byteToString(byte[] byteArray){
		return new String(byteArray);
	}
	
	
	public static String getOpcode(String instruction){
		return instruction.substring(0, 5);
	}
	
	
	public static String getRegisterNumber(String instruction){
		return instruction.substring(6, 9);
	}
	
	
	
	
	
	
	
	
	
	
}
